package main

import (
	"fmt"
	"runtime"
	"time"
)

// goexit关闭线程
func main(){
	go func(){
		defer fmt.Println("defer.B")

		func(){
			defer fmt.Println("defer.A")
			// 退出当前线程
			runtime.Goexit()
			fmt.Println("A")
		}()

		fmt.Println("B")
	}()

	for {
		time.Sleep(1*time.Second)
	}
}